const CryptoJS = require('crypto-js')
/**
 * 加密
 */
function aes_encode(word) {
    var key = CryptoJS.enc.Utf8.parse("This is a key123");
    var srcs = CryptoJS.enc.Utf8.parse(word);
    var encrypted = CryptoJS.AES.encrypt(srcs, 'This is a key123', {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}
/**
 * 解密
 */
function aes_decode(word) {
    var key = CryptoJS.enc.Utf8.parse("This is a key123");
    var decrypt = CryptoJS.AES.decrypt(word, 'This is a key123', {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}

// 会生成随机密文
// en_code = aes_encode('123456789012345+' + String(Date.now()))
en_code = aes_encode('1234567890123456')
console.log('加密：',en_code)
console.log('解密：',aes_decode(en_code))